package com.sikaryofficial.system.api.config;

import cn.hutool.crypto.Mode;
import cn.hutool.crypto.Padding;
import cn.hutool.crypto.symmetric.AES;

import java.nio.charset.StandardCharsets;

/**
 * AES解密组件
 *
 * @author feng
 */
public class AESDecryptComponent implements DecryptComponent {

    /**
     * 生成密钥，16、24、32位都行
     */
    private final static byte[] SECURE_KEY = "d3uj1amxbu084ijruu4zgw9mjfvuwfz7".getBytes(StandardCharsets.UTF_8);

    /**
     * 偏移量，必须16位
     */
    private final static String IV = "hy6r0fc6pd8o9scs";

    private final static AES AES_INSTANCE = new AES(Mode.CBC, Padding.PKCS5Padding, SECURE_KEY, IV.getBytes(StandardCharsets.UTF_8));

    @Override
    public String decrypt(String encryptedText) {
        return AES_INSTANCE.decryptStr(encryptedText);
    }
}
